<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="it.polimi.swimv2.entities.HelpRequest" %>
<%@ page import="java.util.*" %>
<%@page import="util.RequestStatusPrinter"%>
<%@page import="it.polimi.swimv2.entities.RequestStatus"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Swim 2.0</title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link href="layout.css" rel="stylesheet" type="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>


<div id="container">
<div id="masthead" class="navBG">
	<%@ include file="log.jsp" %>
</div>
	<div id="left_col" class="navBG">
		<%@ include file="menu.jsp" %>
	</div>
	<div id="page_content">
	<div class="tableTitle">
	Richieste Aiuto Ricevute:</div>
<% Collection<HelpRequest> receivedRequests = (Collection<HelpRequest>) request.getAttribute("receivedRequests");
	if(receivedRequests== null || receivedRequests.isEmpty()) {%>	
	<div class="heading">
	Non hai Richieste Aiuto Ricevute!</div>
<% }else{ %>
	
	<table class="resultTable">
	<tr>
		<td class="listTitle">Data</td>
		<td class="listTitle"> Oggetto</td>
		<td class="listTitle">Mittente</td>
		<td class="listTitle">Stato</td>
		<td class="listTitle">Dettaglio</td>
	</tr>
<% for(HelpRequest rq: receivedRequests){ %>
	<tr>
		<td class="listCell"><%= rq.getDate() %></td>
		<td class="listCell"><%= rq.getObject() %></td>
		<td class="listCell"><a href="UserProfileServlet?act=showUserProfile&username=<%= rq.getSender().getUsername()%>"> <%= rq.getSender().getUsername()%></a></td>
		<td class="listCell"><%= RequestStatusPrinter.print(rq.getStatus()) %></td>
		<td class="listCell"><a href="HelpRequestServlet?act=showRequestDetails&rqID=<%= rq.getId().toString() %>"> dettaglio </a></td>
	</tr>
<% } %>
	</table>
<% } %>	
	<div class="tableTitle">
	Richieste Aiuto Inviate:</div>
<% Collection<HelpRequest> sentRequests = (Collection<HelpRequest>) request.getAttribute("sentRequests");
	if(sentRequests== null || sentRequests.isEmpty()) {%>
	<div class="heading">
	Non hai Richieste Aiuto Inviate!</div>
<% }else{ %>
	
	<table class="resultTable">
	<tr>
		<td class="listTitle">Data</td>
		<td class="listTitle"> Oggetto</td>
		<td class="listTitle">Destinatario</td>
		<td class="listTitle">Stato</td>
		<td class="listTitle">Dettaglio</td>
	</tr>
<% for(HelpRequest rq: sentRequests){ %>
	<tr>
		<td class="listCell"><%= rq.getDate() %></td>
		<td class="listCell"><%= rq.getObject() %></td>
		<td class="listCell"><a href="UserProfileServlet?act=showUserProfile&username=<%= rq.getReceiver().getUsername()%>"> <%= rq.getReceiver().getUsername()%></a></td>
		<td class="listCell"><%= RequestStatusPrinter.print(rq.getStatus()) %></td>
		<td class="listCell"><a href="HelpRequestServlet?act=showRequestDetails&rqID=<%= rq.getId().toString() %>"> dettaglio </a></td>
	</tr>
<% } %>
	</table>
<% } %>	
	</div>
	<div id="footer" class="navBG">
	<p> Aliprandi-Belladelli </p>
</div>
</div>
</body>
</html>
